var Mock = require('./mock.js')

class Ajax {
  classic(fn, data = '', method = 'get', header = {}) {
    let res = Mock.mock({
      list1: {
        'content': "人生不能像做菜，把所有的料准备好才下锅",
        'fav_nums': 451,
        'id': 1,
        'image': "http://bl.7yue.pro/images/movie.8.png",
        'index': 3,
        'like_status': 0,
        'pubdate': "2018-06-22",
        'title': "李安《饮食男女 》",
        'type': 100
      },
      list2: {
        'content': "谁念过 千字文章 秋收冬已藏",
        'fav_nums': 284,
        'id': 1,
        'image': "http://bl.7yue.pro/images/music.7.png",
        'index': 2,
        'like_status': 1,
        'pubdate': "2018-06-22",
        'title': "不才 《参商》",
        'type': 200,
        'url': "http://music.163.com/song/media/outer/url?id=29719651.mp3"
      }
    })
    fn(res)
  }

  books(fn, data = '', method = 'get', header = {}) {
    let res = Mock.mock([{
      "author": "[\u7f8e]\u4fdd\u7f57\u00b7\u683c\u96f7\u5384\u59c6",
      "fav_nums": 225,
      "id": 7,
      "image": "https://img3.doubanio.com/lpic/s4669554.jpg",
      "like_status": 1,
      "title": "\u9ed1\u5ba2\u4e0e\u753b\u5bb6"
    }, {
      "author": "MarkPilgrim",
      "fav_nums": 128,
      "id": 65,
      "image": "https://img3.doubanio.com/lpic/s4059293.jpg",
      "like_status": 1,
      "title": "Dive Into Python 3"
    }, {
      "author": "MagnusLieHetland",
      "fav_nums": 72,
      "id": 183,
      "image": "https://img3.doubanio.com/lpic/s4387251.jpg",
      "like_status": 0,
      "title": "Python\u57fa\u7840\u6559\u7a0b"
    }, {
      "author": "[\u54e5\u4f26\u6bd4\u4e9a]\u52a0\u897f\u4e9a\u00b7\u9a6c\u5c14\u514b\u65af",
      "fav_nums": 96,
      "id": 1002,
      "image": "https://img3.doubanio.com/lpic/s6384944.jpg",
      "like_status": 0,
      "title": "\u767e\u5e74\u5b64\u72ec"
    }, {
      "author": "[\u65e5]\u5ca9\u4e95\u4fca\u4e8c",
      "fav_nums": 59,
      "id": 1049,
      "image": "https://img1.doubanio.com/view/subject/l/public/s29775868.jpg",
      "like_status": 0,
      "title": "\u60c5\u4e66"
    }, {
      "author": "[\u7f8e]\u4e54\u6cbb\u00b7R\u00b7R\u00b7\u9a6c\u4e01",
      "fav_nums": 42,
      "id": 1061,
      "image": "https://img3.doubanio.com/lpic/s1358984.jpg",
      "like_status": 0,
      "title": "\u51b0\u4e0e\u706b\u4e4b\u6b4c\uff08\u5377\u4e00\uff09"
    }, {
      "author": "[\u65e5]\u4e1c\u91ce\u572d\u543e",
      "fav_nums": 75,
      "id": 1120,
      "image": "https://img3.doubanio.com/lpic/s4610502.jpg",
      "like_status": 1,
      "title": "\u767d\u591c\u884c"
    }, {
      "author": "\u91d1\u5eb8",
      "fav_nums": 32,
      "id": 1166,
      "image": "https://img1.doubanio.com/lpic/s23632058.jpg",
      "like_status": 0,
      "title": "\u5929\u9f99\u516b\u90e8"
    }, {
      "author": "[\u65e5]\u4e1c\u91ce\u572d\u543e",
      "fav_nums": 16,
      "id": 1308,
      "image": "https://img3.doubanio.com/lpic/s3814606.jpg",
      "like_status": 0,
      "title": "\u6076\u610f"
    }, {
      "author": "[\u82f1]J\u00b7K\u00b7\u7f57\u7433",
      "fav_nums": 28,
      "id": 1339,
      "image": "https://img3.doubanio.com/lpic/s1074376.jpg",
      "like_status": 0,
      "title": "\u54c8\u5229\u00b7\u6ce2\u7279\u4e0e\u963f\u5179\u5361\u73ed\u7684\u56da\u5f92"
    }, {
      "author": "\u97e9\u5bd2",
      "fav_nums": 13,
      "id": 1383,
      "image": "https://img1.doubanio.com/lpic/s3557848.jpg",
      "like_status": 0,
      "title": "\u4ed6\u7684\u56fd"
    }, {
      "author": "[\u82f1]J\u00b7K\u00b7\u7f57\u7433",
      "fav_nums": 21,
      "id": 1398,
      "image": "https://img1.doubanio.com/lpic/s2752367.jpg",
      "like_status": 0,
      "title": "\u54c8\u5229\u00b7\u6ce2\u7279\u4e0e\u6b7b\u4ea1\u5723\u5668"
    }, {
      "author": "\u738b\u5c0f\u6ce2",
      "fav_nums": 20,
      "id": 1560,
      "image": "https://img1.doubanio.com/lpic/s3463069.jpg",
      "like_status": 0,
      "title": "\u4e09\u5341\u800c\u7acb"
    }, {
      "author": "[\u4f0a\u6717]\u739b\u8d5e\u00b7\u838e\u5854\u78a7",
      "fav_nums": 14,
      "id": 7821,
      "image": "https://img3.doubanio.com/lpic/s6144591.jpg",
      "like_status": 0,
      "title": "\u6211\u5728\u4f0a\u6717\u957f\u5927"
    }, {
      "author": "[\u65e5]\u6751\u4e0a\u6625\u6811",
      "fav_nums": 10,
      "id": 8854,
      "image": "https://img1.doubanio.com/lpic/s29494718.jpg",
      "like_status": 0,
      "title": "\u8fdc\u65b9\u7684\u9f13\u58f0"
    }, {
      "author": "\u4e09\u6bdb",
      "fav_nums": 9,
      "id": 8866,
      "image": "https://img3.doubanio.com/lpic/s2393243.jpg",
      "like_status": 0,
      "title": "\u68a6\u91cc\u82b1\u843d\u77e5\u591a\u5c11"
    }, {
      "author": "\u97e9\u5bd2",
      "fav_nums": 17,
      "id": 15198,
      "image": "https://img1.doubanio.com/lpic/s1080179.jpg",
      "like_status": 0,
      "title": "\u50cf\u5c11\u5e74\u5566\u98de\u9a70"
    }, {
      "author": "\u9c81\u8fc5",
      "fav_nums": 29,
      "id": 15984,
      "image": "https://img3.doubanio.com/lpic/s27970504.jpg",
      "like_status": 0,
      "title": "\u671d\u82b1\u5915\u62fe"
    }, {
      "author": "[\u65e5]\u4e95\u4e0a\u96c4\u5f66",
      "fav_nums": 21,
      "id": 21050,
      "image": "https://img3.doubanio.com/lpic/s2853431.jpg",
      "like_status": 0,
      "title": "\u704c\u7bee\u9ad8\u624b31"
    }, {
      "author": "[\u65e5]\u65b0\u4e95\u4e00\u4e8c\u4e09",
      "fav_nums": 25,
      "id": 51664,
      "image": "https://img3.doubanio.com/lpic/s29034294.jpg",
      "like_status": 0,
      "title": "\u4e1c\u4eac\u65f6\u5473\u8bb0"
    }])
    fn(res)
  }

  book_detail(fn, data = '', method = 'get', header = {}) {
    let res = Mock.mock({
      detail: {
        "author": ["[美]保罗·格雷厄姆"],
        "binding": "\u5e73\u88c5",
        "category": "\u7f16\u7a0b",
        "id": 7,
        "image": "https://img3.doubanio.com/lpic/s4669554.jpg",
        "images": {
          "large": "https://img3.doubanio.com/lpic/s4669554.jpg"
        },
        "isbn": "9787115249494",
        "pages": "264",
        "price": "49.00\u5143",
        "pubdate": "2011-4",
        "publisher": "\u4eba\u6c11\u90ae\u7535\u51fa\u7248\u793e",
        "subtitle": "\u7845\u8c37\u521b\u4e1a\u4e4b\u7236Paul Graham\u6587\u96c6",
        "summary": "\u672c\u4e66\u662f\u7845\u8c37\u521b\u4e1a\u4e4b\u7236Paul Graham \u7684\u6587\u96c6\uff0c\u4e3b\u8981\u4ecb\u7ecd\u9ed1\u5ba2\u5373\u4f18\u79c0\u7a0b\u5e8f\u5458\u7684\u7231\u597d\u548c\u52a8\u673a\uff0c\u8ba8\u8bba\u9ed1\u5ba2\u6210\u957f\u3001\u9ed1\u5ba2\u5bf9\u4e16\u754c\u7684\u8d21\u732e\u4ee5\u53ca\u7f16\u7a0b\u8bed\u8a00\u548c\u9ed1\u5ba2\u5de5\u4f5c\u65b9\u6cd5\u7b49\u6240\u6709\u5bf9\u8ba1\u7b97\u673a\u65f6\u4ee3\u611f\u5174\u8da3\u7684\u4eba\u7684\u4e00\u4e9b\u8bdd\u9898\u3002\u4e66\u4e2d\u7684\u5185\u5bb9\u4e0d\u4f46\u6709\u52a9\u4e8e\u4e86\u89e3\u8ba1\u7b97\u673a\u7f16\u7a0b\u7684\u672c\u8d28\u3001\u4e92\u8054\u7f51\u884c\u4e1a\u7684\u89c4\u5219\uff0c\u8fd8\u4f1a\u5e2e\u52a9\u8bfb\u8005\u4e86\u89e3\u6211\u4eec\u8fd9\u4e2a\u65f6\u4ee3\uff0c\u8feb\u4f7f\u8bfb\u8005\u72ec\u7acb\u601d\u8003\u3002\\n\u672c\u4e66\u9002\u5408\u6240\u6709\u7a0b\u5e8f\u5458\u548c\u4e92\u8054\u7f51\u521b\u4e1a\u8005\uff0c\u4e5f\u9002\u5408\u4e00\u5207\u5bf9\u8ba1\u7b97\u673a\u884c\u4e1a\u611f\u5174\u8da3\u7684\u8bfb\u8005\u3002",
        "title": "\u9ed1\u5ba2\u4e0e\u753b\u5bb6",
        "translator": ["\u962e\u4e00\u5cf0"]
      },
      short_comment: {
        "book_id": 7,
        "comments": [{
          "content": "\u7a0b\u5e8f\u5458\u4e5f\u6709\u827a\u672f\u7684\u4eba\u751f",
          "nums": 3112
        }, {
          "content": "\u9ed1\u5ba2and",
          "nums": 1339
        }, {
          "content": "\u4e03\u6708\u8001\u5e08\u597d",
          "nums": 489
        }, {
          "content": "a",
          "nums": 53
        }, {
          "content": "2",
          "nums": 41
        }, {
          "content": "hello,world",
          "nums": 36
        }, {
          "content": "\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\u5341\u5341\u4e00",
          "nums": 33
        }, {
          "content": "\u4e70\u4e86\u4f5b\u51b7",
          "nums": 29
        }, {
          "content": "\u827a\u672f",
          "nums": 27
        }, {
          "content": "\u4f60\u597d",
          "nums": 24
        }]
      },
      favor: {
        "fav_nums": 225,
        "id": 7,
        "like_status": 1
      }
    })
    fn(res)
  }

  searchBooks(fn, data = '', method = 'get', header = {}) {
    let res = Mock.mock({
      "books": [{
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1031,
        "image": "https://img3.doubanio.com/lpic/s1228930.jpg",
        "isbn": "9787532725694",
        "price": "18.80\u5143",
        "title": "\u632a\u5a01\u7684\u68ee\u6797"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1034,
        "image": "https://img3.doubanio.com/lpic/s4363464.jpg",
        "isbn": "9787544247269",
        "price": "36.00\u5143",
        "title": "1Q84 BOOK 1"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1043,
        "image": "https://img1.doubanio.com/lpic/s1801057.jpg",
        "isbn": "9787532730001",
        "price": "23.00\u5143",
        "title": "\u4e16\u754c\u5c3d\u5934\u4e0e\u51b7\u9177\u4ed9\u5883"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1051,
        "image": "https://img3.doubanio.com/lpic/s1094940.jpg",
        "isbn": "9787532734191",
        "price": "25.00\u5143",
        "title": "\u6d77\u8fb9\u7684\u5361\u592b\u5361"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1106,
        "image": "https://img3.doubanio.com/lpic/s4393610.jpg",
        "isbn": "9787544247252",
        "price": "36.00\u5143",
        "title": "1Q84 BOOK 2"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1156,
        "image": "https://img1.doubanio.com/lpic/s1029019.jpg",
        "isbn": "9787532726172",
        "price": "11.80\u5143",
        "title": "\u4e14\u542c\u98ce\u541f"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1225,
        "image": "https://img3.doubanio.com/lpic/s2333463.jpg",
        "isbn": "9787532726745",
        "price": "13.50\u5143",
        "title": "\u56fd\u5883\u4ee5\u5357 \u592a\u9633\u4ee5\u897f"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1281,
        "image": "https://img3.doubanio.com/lpic/s1231290.jpg",
        "isbn": "9787532728893",
        "price": "25.00\u5143",
        "title": "\u821e\uff01\u821e\uff01\u821e\uff01"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1310,
        "image": "https://img3.doubanio.com/lpic/s4577386.jpg",
        "isbn": "9787544249867",
        "price": "39.50\u5143",
        "title": "1Q84 BOOK 3"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1320,
        "image": "https://img1.doubanio.com/lpic/s1231309.jpg",
        "isbn": "9787532729531",
        "price": "30.00\u5143",
        "title": "\u5947\u9e1f\u884c\u72b6\u5f55"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1380,
        "image": "https://img1.doubanio.com/lpic/s1738888.jpg",
        "isbn": "9787532740536",
        "price": "13.00\u5143",
        "title": "\u4e1c\u4eac\u5947\u8c2d\u96c6"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1517,
        "image": "https://img1.doubanio.com/lpic/s1029647.jpg",
        "isbn": "9787532726141",
        "price": "18.80\u5143",
        "title": "\u5bfb\u7f8a\u5192\u9669\u8bb0"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1597,
        "image": "https://img1.doubanio.com/lpic/s1014359.jpg",
        "isbn": "9787532726271",
        "price": "14.10\u5143",
        "title": "\u65af\u666e\u7279\u5c3c\u514b\u604b\u4eba"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1645,
        "image": "https://img3.doubanio.com/lpic/s3028674.jpg",
        "isbn": "9787532730131",
        "price": "13.50\u5143",
        "title": "\u9047\u5230\u767e\u5206\u4e4b\u767e\u7684\u5973\u5b69"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 1829,
        "image": "https://img3.doubanio.com/lpic/s1231283.jpg",
        "isbn": "9787532728879",
        "price": "13.50\u5143",
        "title": "\u795e\u7684\u5b69\u5b50\u5168\u8df3\u821e"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 8854,
        "image": "https://img1.doubanio.com/lpic/s29494718.jpg",
        "isbn": "9787532754533",
        "price": "32.00\u5143",
        "title": "\u8fdc\u65b9\u7684\u9f13\u58f0"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 8858,
        "image": "https://img3.doubanio.com/lpic/s1228923.jpg",
        "isbn": "9787532726325",
        "price": "12.40\u5143",
        "title": "\u518d\u88ad\u9762\u5305\u5e97"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 8859,
        "image": "https://img1.doubanio.com/lpic/s1041079.jpg",
        "isbn": "9787532726288",
        "price": "12.50\u5143",
        "title": "\u4e00\u4e5d\u4e03\u4e09\u5e74\u7684\u5f39\u5b50\u7403"
      }, {
        "author": ["[\u65e5] \u6751\u4e0a\u6625\u6811 \u6587", "[\u65e5] \u548c\u7530\u8bda \u753b"],
        "id": 8874,
        "image": "https://img3.doubanio.com/lpic/s1958725.jpg",
        "isbn": "9787532729371",
        "price": "20.00\u5143",
        "title": "\u7235\u58eb\u4e50\u7fa4\u82f1\u8c31"
      }, {
        "author": ["[\u65e5]\u6751\u4e0a\u6625\u6811"],
        "id": 8875,
        "image": "https://img3.doubanio.com/lpic/s2001280.jpg",
        "isbn": "9787532732319",
        "price": "15.00\u5143",
        "title": "\u7ec8\u7a76\u60b2\u54c0\u7684\u5916\u56fd\u8bed"
      }],
      "count": 20,
      "start": 0,
      "total": 167
    })
    fn(res)
  }

  hotKeyword(fn, data = '', method = 'get', header = {}) {
    let res = Mock.mock({
      "hot": ["Python", "\u54c8\u5229\u00b7\u6ce2\u7279", "\u6751\u4e0a\u6625\u6811", "\u4e1c\u91ce\u572d\u543e", "\u767d\u591c\u884c", "\u97e9\u5bd2", "\u91d1\u5eb8", "\u738b\u5c0f\u6ce2"]
    })

    fn(res)
  }

  favor(fn, data = '', method = 'get', header = {}) {
    let res = Mock.mock([{
      "content": "\u8c01\u5ff5\u8fc7 \u5343\u5b57\u6587\u7ae0 \u79cb\u6536\u51ac\u5df2\u85cf",
      "fav_nums": 286,
      "id": 1,
      "image": "http://bl.7yue.pro/images/music.7.png",
      "like_status": 1,
      "type": 200
    }, {
      "content": "\u5728\u53d8\u6362\u7684\u751f\u547d\u91cc\uff0c\u5c81\u6708\u539f\u6765\u662f\u6700\u5927\u7684\u5c0f\u5077",
      "fav_nums": 138,
      "id": 2,
      "image": "http://bl.7yue.pro/images/movie.4.png",
      "like_status": 1,
      "type": 100
    }, {
      "content": "\u8bb8\u591a\u4eba\u6765\u6765\u53bb\u53bb\uff0c\u76f8\u805a\u53c8\u522b\u79bb",
      "fav_nums": 191,
      "id": 4,
      "image": "http://bl.7yue.pro/images/music.5.png",
      "like_status": 1,
      "type": 200
    }, {
      "content": "\u4f60\u966a\u6211\u6b65\u5165\u8749\u590f \u8d8a\u8fc7\u57ce\u5e02\u55a7\u56a3",
      "fav_nums": 142,
      "id": 2,
      "image": "http://bl.7yue.pro/images/music.1.png",
      "like_status": 1,
      "type": 200
    }, {
      "content": "\u5fc3\u4e0a\u65e0\u57a2\uff0c\u6797\u95f4\u6709\u98ce",
      "fav_nums": 215,
      "id": 1,
      "image": "http://bl.7yue.pro/images/sentence.6.png",
      "like_status": 1,
      "type": 300
    }])

    fn(res)
  }
}

export {
  Ajax
}